package com.nbpt;

import android.Manifest;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.graphics.Paint;
import android.net.Uri;
import android.os.Parcel;
import android.support.annotation.Nullable;
import android.support.v4.app.ActivityCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import java.util.List;

public class ContactUsActivity extends AppCompatActivity {
    TextView TvPhone,TvHttp,TvLocation;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_contact_us);
        getSupportActionBar().setTitle("联系我们");
        ViewInit();
        if (checkSelfPermission(Manifest.permission.CALL_PHONE)!=PackageManager.PERMISSION_GRANTED){
            ActivityCompat.requestPermissions(this,new String[] {Manifest.permission.CALL_PHONE},0);
        }
        if (checkSelfPermission(Manifest.permission.INTERNET)!=PackageManager.PERMISSION_GRANTED){
            ActivityCompat.requestPermissions(this,new String[] {Manifest.permission.INTERNET},1);
        }
    }


//    public void sendIntent(View view) {
//        Intent intent = new Intent(Intent.ACTION_CALL);
//        intent.addCategory(Intent.CATEGORY_DEFAULT);
//        Uri uri = Uri.parse("tel://123123123");
//        intent.setData(uri);
//        //intent.putExtra("sms_body","This is a message!");
//        startActivity(intent);
//    }

    public void ViewInit(){
        TvPhone=findViewById(R.id.tvPhone);
        TvHttp=findViewById(R.id.tvHttp);
        TvLocation=findViewById(R.id.Location);
        TvHttp.setPaintFlags(TvHttp.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
        TvPhone.setPaintFlags(TvPhone.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
        TvLocation.setPaintFlags(TvLocation.getPaintFlags() | Paint.UNDERLINE_TEXT_FLAG);
    }

    public void Phone(View view) {
        Intent intent = new Intent(Intent.ACTION_CALL);
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        Uri uri = Uri.parse("tel://0574-86891367");
        intent.setData(uri);
        //intent.putExtra("sms_body","This is a message!");
        startActivity(intent);
    }

    public void Http(View view) {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        Uri uri = Uri.parse("http://www.nbpt.edu.cn");
        intent.setData(uri);
        //intent.putExtra("sms_body","This is a message!");
        startActivity(intent);
    }

    public void Location(View view) {
        Intent intent = new Intent(Intent.ACTION_VIEW);
        intent.addCategory(Intent.CATEGORY_DEFAULT);
        Uri uri = Uri.parse("baidumap://map/direction?origin=name:我的位置|latlng:当前纬度,当前经度&destination=宁波经济技术开发区新大路1069号&latlng=116.404987,39.914431&mode=driving&region=宁波");
        intent.setData(uri);
        //intent.putExtra("sms_body","This is a message!");
        startActivity(intent);
    }
}
